﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for MerchantPackageDB
/// </summary>
namespace CE.CarInsurance
{
    public class MerchantPackageDB
    {
        public Int64 Insert(MerchantPackage merchantpackage)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocMerchantPackageCarDetailsInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@CarId", merchantpackage.CarId);
            _sPara.Add("@MerchantId", merchantpackage.MerchantId);
            _sPara.Add("@ProviderCompanyId", merchantpackage.ProviderCompanyId);
            _sPara.Add("@Title", merchantpackage.Title);
            _sPara.Add("@CustomerType", merchantpackage.CustomerType);
            _sPara.Add("@CustomerName", merchantpackage.CustomerName);
            _sPara.Add("@Name", merchantpackage.Name);
            _sPara.Add("@DOB", merchantpackage.DOB);
            _sPara.Add("@Gender", merchantpackage.Gender);
            _sPara.Add("@Occupation", merchantpackage.Occupation);
            _sPara.Add("@ContactNo", merchantpackage.ContactNo);
            _sPara.Add("@OfficePhoneNo", merchantpackage.OfficePhoneNo);
            _sPara.Add("@IdentificationNo", merchantpackage.IdentificationNo);
            _sPara.Add("@PresentAddress", merchantpackage.PresentAddress);
            _sPara.Add("@SubDistrict", merchantpackage.SubDistrict);
            _sPara.Add("@District", merchantpackage.District);
            _sPara.Add("@Province", merchantpackage.Province);
            _sPara.Add("@PostalCode", merchantpackage.PostalCode);
            _sPara.Add("@Package", merchantpackage.Package);
            _sPara.Add("@NoOfDriver", merchantpackage.NoOfDriver);
            _sPara.Add("@InsuranceType", merchantpackage.InsuranceType);
            _sPara.Add("@GarageType", merchantpackage.GarageType);
            _sPara.Add("@CarYear", merchantpackage.CarYear);
            _sPara.Add("@CarModel", merchantpackage.CarModel);
            //_sPara.Add("@Size", fleetpackage.Size);
            //_sPara.Add("@VehicleWeight", fleetpackage.VehicleWeight);
            //_sPara.Add("@NumberofSeat", fleetpackage.NumberofSeat);
            _sPara.Add("@Beneficiary", merchantpackage.Beneficiary);
            _sPara.Add("@VehicleType", merchantpackage.VehicleType);
            _sPara.Add("@SumInsured", merchantpackage.SumInsured);
            _sPara.Add("@NCB", merchantpackage.NCB);
            _sPara.Add("@CurrentInsurer", merchantpackage.CurrentInsurer);
            _sPara.Add("@CarPlate", merchantpackage.CarPlate);
            _sPara.Add("@CarPlateProvince", merchantpackage.CarPlateProvince);
            _sPara.Add("@EngineNumber", merchantpackage.EngineNumber);
            _sPara.Add("@ChassisNumber", merchantpackage.ChassisNumber);
            //_sPara.Add("@IsModification", fleetpackage.IsModification);
            //_sPara.Add("@IsClaim", fleetpackage.IsClaim);
            _sPara.Add("@CoverageStart", merchantpackage.CoverageStart);
            _sPara.Add("@Premium", merchantpackage.Premium);
            _sPara.Add("@IsCTPL", merchantpackage.IsCTPL);
            _sPara.Add("@CTPL", merchantpackage.CTPL);
            _sPara.Add("@CTPLStart", merchantpackage.CTPLStart);
            _sPara.Add("@TotalCollectedPremium", merchantpackage.TotalCollectedPremium);
            _sPara.Add("@TotalPremium", merchantpackage.TotalPremium);
            _sPara.Add("@TermPremium", merchantpackage.TermPremium);
            _sPara.Add("@PaymentStatus", merchantpackage.PaymentStatus);
            _sPara.Add("@QuoteRefNo", merchantpackage.QuoteRefNo);
            _sPara.Add("@Status", merchantpackage.Status);
            _sPara.Add("@RefCEUserId", merchantpackage.RefCEUserId);
            _sPara.Add("@AgentId", merchantpackage.AgentId);
            _sPara.Add("@AdminId", merchantpackage.AdminId);
            _sPara.Add("@Info1", merchantpackage.Info1); // Application Type
            _sPara.Add("@Info2", merchantpackage.Info2); // Last Year Policy No.
            _sPara.Add("@Info3", merchantpackage.Info3);
            _sPara.Add("@IsCreditCardOwner", merchantpackage.IsCreditCardOwner); // tblCEUsrProfile table Ninfo5 field
            _sPara.Add("@Info4", merchantpackage.Info4); //Accessories or Modifications Cost
            _sPara.Add("@Info8", merchantpackage.Info8); //Agent Remarks
            _sPara.Add("@PromotionCode", merchantpackage.PromotionCode);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataSet GetCarDetails(Int64 CarId)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            string _spName = "sprocMerchantPackageCarDetailsSelectedItemByCarId";

            SortedList _spara = new SortedList();
            _spara.Add("@CarId", CarId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetCarDetails(Int64 CarId, Int64 CustomerId)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            string _spName = "sprocMerchantPackageCarDetailsSelectedItemByCarId";

            SortedList _spara = new SortedList();
            _spara.Add("@CarId", CarId);
            _spara.Add("@CustomerId", CustomerId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetMerchantApplication(Int64 CarId, Int64 ProviderId, Int16 IsInternal)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            string _spName = "sprocMerchantApplicationSelectItem";

            SortedList _spara = new SortedList();
            _spara.Add("@CarId", CarId);
            _spara.Add("@ProviderCompanyId", ProviderId);
            _spara.Add("@IsInternal", IsInternal);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetLastYearCarDetails(Int64 CarId, string LYrQuoteRefNo)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            string _spName = "sprocMerchantPackageExsitingItemSelectByQuoteRefNo";

            SortedList _spara = new SortedList();
            _spara.Add("@CarId", CarId);
            _spara.Add("@LYrQuoteRefNo", LYrQuoteRefNo);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public Int64 UpdateApplicationCancelStatus(Int64 CarId, Int64 ProviderId, Int64 AgentId, Int64 AdminId, Int16 Step, string Remarks)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocMerchantApplicationCancelUpdateSelectItem";
            SortedList _sPara = new SortedList();
            #region Parameter
            _sPara.Add("@CarId", CarId);
            _sPara.Add("@ProviderCompanyId", ProviderId);
            _sPara.Add("@AgentId", AgentId);
            _sPara.Add("@AdminId", AdminId);
            _sPara.Add("@Step", Step);
            _sPara.Add("@Remarks", Remarks);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);
            return _result;
        }

        public Int64 UpdateApplicationRetrieveStatus(Int64 CarId, Int64 ProviderId, Int64 AgentId, Int64 AdminId, Int16 Step, String QuoteRefNo)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocMerchantApplicationCancelUpdateSelectItem";
            SortedList _sPara = new SortedList();
            #region Parameter
            _sPara.Add("@CarId", CarId);
            _sPara.Add("@ProviderCompanyId", ProviderId);
            _sPara.Add("@AgentId", AgentId);
            _sPara.Add("@AdminId", AdminId);
            _sPara.Add("@Step", Step);
            _sPara.Add("@QuoteRefNo", QuoteRefNo);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);
            return _result;
        }

        public Int64 UpdateExcelName(Int64 CarId, string Excel)
        {
            MyDatabase _db = new MyDatabase("GG_MCDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocMerchantExcelNameUpdatedSelectItem";
            SortedList _sPara = new SortedList();
            #region Parameter
            _sPara.Add("@CarId", CarId);
            _sPara.Add("@Excel", Excel);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);
            return _result;
        }
    }
}
